package net.dreamlu.controller.api;

import java.io.BufferedOutputStream;
import java.io.IOException;

import net.dreamlu.kit.ImageKit;

import com.jfinal.core.Controller;

/**
 * 二维码
 * @author L.cm
 * @date Oct 26, 2013 10:34:10 AM
 */
public class QRcode extends Controller {
	
	public void index() throws IOException {
		String text = getPara("text", "http://www.dreamlu.net/");
		byte[] bs = ImageKit.qRcode(text, 90);
		BufferedOutputStream bos = new BufferedOutputStream(
	    getResponse().getOutputStream());
	    bos.write(bs, 0, bs.length);
	    if (bos != null) {
	    	bos.close();
	    }
    	bos.flush();
    	return;
	}
}
